from flask import Blueprint
from flask_cors import CORS
from web_server.apis.v1.resources import (
    IndexAPI,
    SystemOpenAPI,
    SystemCloseAPI,
    SystemIsOpenedAPI,
    DecectAPI,
)

api_v1 = Blueprint("api_v1", __name__)

CORS(api_v1)
api_v1.add_url_rule("/", view_func=IndexAPI.as_view("index"), methods=["GET"])
api_v1.add_url_rule(
    "/isOpened", view_func=SystemIsOpenedAPI.as_view("isOpened"), methods=["GET"]
)
api_v1.add_url_rule(
    "/open", view_func=SystemOpenAPI.as_view("SystemOpen"), methods=["GET"]
)
api_v1.add_url_rule(
    "/close", view_func=SystemCloseAPI.as_view("SystemClose"), methods=["GET"]
)
api_v1.add_url_rule("/up", view_func=DecectAPI.as_view("detect"), methods=["POST"])
